home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Revista CD Expert 32
/
CD Expert nº 32.iso
/
Army Men TiS
/
data1.cab
/
Required_Files
/
rules
/
caf_ai.txt
< prev
next >
Wrap
Text File
|
1999-10-08
|
5KB
|
175 lines
// this gets loaded on the host if the @1 army is AI controlled
// @1 = color to do AI for, @2 = color of enemy, @3 = value for @1Action variable
macro caf_ai_enemy 3
{
// these events setup the @1Action variable
// before attacking @2 make sure @2 is in the game and is not an ally
if @1SetCapture@2 testvar IsColorInGame @2 > 0 and IsAlly @1 @2 = 0
and @1Captured@2Flag = 0 then
setvar @1Action @3,
trigger @1PerformAction
if @1PerformAction testvar @1Action = @3 then
order @1sarge1 follow @2flag1 inmode attack,
order @1 group 1 follow @1sarge1 inmode defend,
order @1 group 2 follow @2flag1 inmode attack,
order @1 group 3 follow @2flag1 inmode attack
// these events choose new actions if my flag is captured by an enemy
if pickedup @1flag1 by @2 testvar isAlly @1 @2 = 0 and @1Action < 5 then
setvar @1Action 4,
trigger @1PerformAction
// these events choose new actions if I capture an enemy flag
if pickedup @2flag1 by @1 testvar isAlly @1 @2 = 0 and @1Captured@2Flag = 0 then
setvar @1Action 5,
trigger @1PerformAction
// these events choose new actions if any other flag is captured by an enemy
if pickedup @2flag1 testvar @1Action < 4
and isAlly @1 @2 = 0 and @1Captured@2Flag = 0 then
setvar @1Action @3,
trigger @1PerformAction
}
// @1 = color to do AI for, @2 = color of flag
macro caf_check_holding_my_flag 2
{
if @1CheckIfHoldingFlags testvar hasitem @1sarge1 @2flag1 = 1 then
setvar @1Action 5,
trigger @1PerformAction
}
// @1 = color to do AI for, @2 = color of flag
macro caf_check_holding_flag 2
{
if @1CheckIfHoldingFlags testvar hasitem @1sarge1 @2flag1 = 1
and @1Captured@2Flag = 0 then
setvar @1Action 5,
trigger @1PerformAction
}
// @1 = color of army to do AI for, @2-@4 = other colors
// @5 = letters to identify flagbase (e.g. "b" for blue, "gr" for grey)
macro caf_ai_macro 5
{
// maintain a variable which knows when we are on our base pad
// this is used if we accidentally pickup our own flag and we are already on our base
variable @1OnBase 0
if padon @1base then
setvar @1OnBase 1
if padoff @1base then
setvar @1OnBase 0
// This variable holds the current action for @1
// 0 means no action, 1 means goto @2 flag, 2 means goto @3 flag, 3 means goto @4 flag,
// 4 means rescue @1 flag, 5 means take flag to base
variable @1Action 0
if startup1 then
triggerdelay 1000 @1ChooseNewAction,
triggerdelay 2000 @1RegularOrders
if @1ChooseNewAction then
setvar @1Action 0,
trigger @1CheckIfHoldingFlags,
trigger @1ChooseAction,
trigger @1StartTimeOut
// if it's time to choose a new action but we are currently holding a flag then we should
// always choose to take it to a base
expand caf_check_holding_my_flag ( @1 @1 )
expand caf_check_holding_flag ( @1 @2 )
expand caf_check_holding_flag ( @1 @3 )
expand caf_check_holding_flag ( @1 @4 )
// if @1 has no current action then pick a random action
// keep doing this until an action is set
if @1ChooseAction testvar @1Action = 0 then
trigger @1PickRandomAction,
triggerdelay 1000 @1ChooseAction
if @1PickRandomAction then random
trigger @1SetCapture@2,
trigger @1SetCapture@3,
trigger @1SetCapture@4
expand caf_ai_enemy ( @1 @2 1 )
expand caf_ai_enemy ( @1 @3 2 )
expand caf_ai_enemy ( @1 @4 3 )
// this event is for rescuing our own flag
if @1PerformAction testvar @1Action = 4 then
order @1sarge1 follow @1flag1 inmode attack,
order @1 group 1 follow @1sarge1 inmode defend,
order @1 group 2 follow @1flag1 inmode attack,
order @1 group 3 follow @1flag1 inmode attack
// this event is for taking an enemy flag to my base
if @1PerformAction testvar @1Action = 5 then
order @1sarge1 goto @1base inmode standfire,
order @1 group 1 follow @1sarge1 inmode defend,
order @1 group 2 goto near@1base inmode attack,
order @1 group 3 goto near@1base inmode attack
// these events choose new actions if I rescue my own flag
if pickedup @1flag1 by @1 testvar @1OnBase = 0 then
setvar @1Action 5,
trigger @1PerformAction
if pickedup @1flag1 by @1 testvar @1OnBase = 1 then
triggerdelay 100 @1Drop@1Flag
if @1Drop@1Flag then
dropitem @1sarge1 @1flag1 @5flagbase
// these events chose a new action if we get an enemy flag to home base
if padon @1base then
triggerdelay 1000 @1ChooseNewAction
// if we get our own flag back to base then drop that too
if padon @1base testvar hasitem @1sarge1 @1flag1 = 1 then
dropitem @1sarge1 @1flag1 @5flagbase
// these events choose new actions if a sarge is killed
if killed @1sarge1 then
triggerdelay 5000 @1ChooseNewAction
// these are the standing order regardless of what mode sarge is in
if @1RegularOrders then
trigger @1PerformAction,
setaimode @1 group 4 defend,
setaimode @1 group 5 defend,
order @1 group 7 goto near@1base inmode defend,
triggerdelay 5000 @1RegularOrders
// timeout code - if mode has not changed for a while then change it
variable @1TimeOutVar 0
variable @1LastTimeOutVar 1
if @1StartTimeOut then
addvar @1TimeOutVar 1,
triggerdelay 120000 @1CheckTimeOut
if @1CheckTimeOut testvar @1TimeOutVar = @1LastTimeOutVar then
trigger @1ChooseNewAction
if @1CheckTimeOut testvar @1TimeOutVar <> @1LastTimeOutVar then
addvar @1LastTimeOutVar 1
}